package com.hyz.assetManager.pojo;

import com.alibaba.excel.annotation.ExcelProperty;
import com.hyz.pkg.util.GetValue;
import lombok.Data;
import pojo.asset.asset.Asset;

import java.util.Date;

/**
 * @author HGD
 * @date 2022/9/26 14:07
 */
@Data
public class UploadAsset {
    @ExcelProperty("资产编号")
    private String assetId;
    @ExcelProperty("资产名")
    private String assetName;
    @ExcelProperty("计量单位")
    private String unit;
    @ExcelProperty("购入时间")
    private Date buyDate;
    @ExcelProperty("供应商")
    private String supplier;
    @ExcelProperty("保质期")
    private Date life;

    public Asset getAsset(UploadAsset uploadAsset) {
        return Asset.builder().id(new GetValue().getUuid())
                .assetId(uploadAsset.getAssetId())
                .buyDate(new java.sql.Date(uploadAsset.getBuyDate().getTime()))
                .assetName(uploadAsset.getAssetName())
                .unit(uploadAsset.getUnit())
                .supplier(uploadAsset.getSupplier())
                .life(new java.sql.Date(uploadAsset.getLife().getTime()))
                .build();
    }
}
